var apiUrl = '';
var imageUploadUrl = '';
var imageUploadUrlOnline = '';
var imageSourceUrl = '';
var cabinetUrl = 'https://app.dgsdun.com:8443';

const ServiceManager = require("./service.manager");

const config = require("./apiurl"); 

var initDomainURL = function initDomainURL() {
	var version = "trial";
	// #ifdef MP
	version = __wxConfig.envVersion;
	// #endif
	console.log(version);
	switch (version) {
		case "develop":
			//开发版
			// apiUrl = 'https://apitest.woniugm.com'
			apiUrl = 'https://api.yx2flat.com'
			// apiUrl = 'http://192.168.1.128:8100'
			// apiUrl = 'http://192.168.1.126:8100'
			// apiUrl = 'http://192.168.1.230:8100'; // apiUrl = 'http://192.168.1.124:8100'
			// apiUrl = 'http://192.168.1.121:8100'
			// apiUrl = 'http://192.168.1.220:8100'
			// apiUrl = 'https://api.yx2flat.com'

			// imageUploadUrl: "https://up-z2.qiniup.com",
			// imageSourceUrl = "http://homeimg.hzqiyun.com"; // 七牛云服务图片地址
			
			//线上服务器
			imageUploadUrlOnline = "https://up-z0.qiniup.com"; //七牛云服务上传地址
			imageUploadUrl= "https://upload.qiniup.com"
			//七牛云服务上传地址
			imageSourceUrl= "https://qn-dorm-public.yx2flat.com" // 七牛云服务图片地址
			break;

		case "trial":
			//体验版
			// apiUrl = 'http://192.168.1.121:8100'
			// apiUrl = 'http://192.168.1.124:8100'
			// apiUrl = 'https://api.yx2flat.com'
			// apiUrl = 'http://192.168.1.128:8100'
			// apiUrl = 'https://apitest.woniugm.com'
			// apiUrl = 'http://115.205.217.149:8106'
			const trialApi = config.apiUrl_trial;
			apiUrl = trialApi.apiUrl;
			imageUploadUrl = trialApi.imageUploadUrl; //七牛云服务上传地址

			imageUploadUrlOnline = trialApi.imageUploadUrlOnline; //七牛云服务上传地址

			imageSourceUrl = trialApi.imageSourceUrl; // 七牛云服务图片地址

			break;

		case "release":
			//正式版
			const releaseApi = config.apiUrl_release;
			apiUrl = releaseApi.apiUrl;
			imageUploadUrl = releaseApi.imageUploadUrl; //七牛云服务上传地址

			imageUploadUrlOnline = releaseApi.imageUploadUrlOnline; //七牛云服务上传地址

			imageSourceUrl = releaseApi.imageSourceUrl; // 七牛云服务图片地址

			break;
	} // 为 http request 下钩子
	// if(version === "develop" || version === "trial"){

	apiUrl = ServiceManager.KEY_API_PLACEHODLER;
	ServiceManager.hook_request(); // }
	return {
		apiUrl,
		imageUploadUrl,
		imageSourceUrl,
		imageUploadUrlOnline,
		cabinetUrl,
		mockUrl: 'http://47.98.241.128:9918/mock/17'
	};
}();

module.exports = {
	initDomainURL: initDomainURL
};
